package exercise.day9;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: TODO
 * @date 2022/11/5 0:17
 */
public class CM72_UnusualAdd {
    public int addAB(int A, int B) {
// write code here
        if (B == 0) {
            return A;
        }
        int sum = 0;
        int carray = 0;
        while (B != 0) {
            sum = A ^ B;
            carray = (A & B) << 1;
            A = sum;
            B = carray;
        }
        return A;
    }
}
